public class SetOfStacks{
  ArrayList<Stack> stacks = new ArrayList<Stack>();
  
  public void push(Object item){    //Ask what type it is returning.            //Beautifully done. 
    if(stacks == null || stacks.get(stacks.size()-1).isFull()){
      stacks.add(new Stack);
      stacks.get(stacks.size()-1).push(item);
      }
    else stacks.get(stacks.size()-1).push(item);
  }
  
  public Object pop(){
    Object a = stacks.get(stacks.size()-1).pop();
    if(stacks.get(stacks.size()-1) == null) stacks.setSize(stacks.size()-1);
    return a;
  }
}